<template>
  <div>
    <el-row style="margin-bottom:20px;display:flex;justify-content:space-between">
      <el-input placeholder="仪器设备名称" style="width:20%;margin-right:10px" v-model="searchData.ep_ename" clearable></el-input>
      <el-input placeholder="管理编号" style="width:20%;margin-right:10px" v-model="searchData.managenum" clearable></el-input>
      <el-date-picker
        v-model="jddate"
        clearable
        style="margin-right:15px;width:20%"
        type="daterange"
        rangeSeparator="至"
        startPlaceholder="计划检定/校准开始"
        endPlaceholder="计划检定/校准结束"
        valueFormat="yyyy-MM-dd"
      >
      </el-date-picker>
      <el-select v-model="searchData.status" placeholder="检定状态" style="margin-right:20px;width:20%" clearable>
        <el-option
          v-for="item in checkstatusArr"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        ></el-option>
      </el-select>
      <el-button size="mini" type="primary" @click="getschedulelist">搜索</el-button>
    </el-row>
    <scheduletable :schedulelist="schedulelist" :usertype="4" :pagobj="pagobj" :choosedp.sync="choosedp"
      :ismanager="4"
    ></scheduletable>
  </div>

</template>

<script>
import scheduletable from '~/components/apparatus/eqschedule/scheduletable.vue';

export default {

  components: {
    scheduletable,
  },
  data() {
    return {
      choosedp: [],
      jddate: [],
      searchData: {},
      ts: this.newStore(),
      schedulelist: [],
      checkstatusArr: [{
        label: '已提交证书',
        value: '1',
      }, {
        label: '未提交证书',
        value: '0',
      },
      {
        label: '无需确认',
        value: '2',
      }],
      pagobj: {
        currentPage3: 1,
        pagesize: 10,
        total: 10,
      },
    };
  },
  created() {
    this.getyear();
    this.getschedulelist();
  },
  methods: {
    getyear() {
      const time = new Date();
      const year = time.getFullYear();
      this.jddate = [`${year}-01-01`, `${year}-12-31`];
      console.log(this.jddate);
    },
    getschedulelist() {
      if (this.jddate == null) {
        this.jddate = ['', ''];
      }
      const req = this.searchData;
      req.handle = 'DD5D108B99FC12B782127AB5198E65DA50B1E3C352635A7A4BDCEC5DB08E43DBCD3A43E9777C4E90';
      req.pzrid = localStorage.getItem('pid');
      [req.verifiytime_begin] = [this.jddate[0]];
      [req.verifiytime_end] = [this.jddate[1]];
      req.start = (this.pagobj.currentPage3 - 1) * this.pagobj.pagesize;
      req.limit = this.pagobj.pagesize;
      this.spost(this.ts, '/mainservlet', req).then((ts) => {
        this.schedulelist = ts.d.data.operation1;
        this.pagobj.total = parseInt(ts.d.data.operation2[0].hash.allrs);
      });
    },
    // 公共组件刷新方法
    reload(partsname) {
      this[partsname] = false;
      this.$nextTick(() => {
        this[partsname] = true;
      });
    },
  },
};
</script>

